package com.example.tests;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import java.util.Random;

import org.testng.annotations.Test;

import com.example.utils.SortedListOf;

public class ContactRemovalTests extends TestBase{
	
	@Test
	public void deleteSomeContact(){
		
		//save old contacts list
		SortedListOf<ContactData> oldContacts = app.getContactHelper().getContacts();
				
		//delete contact
		Random rnd = new Random();
		int index = rnd.nextInt(oldContacts.size()-1);
		app.getContactHelper().deleteContact(index);
		
		
		//save new contacts list
		SortedListOf<ContactData> newContacts = app.getContactHelper().getContacts();
		
		//compare lists
		assertThat(newContacts, equalTo(oldContacts.without(index)));
	}

}
